<template>
  <basic-container>
    <avue-crud :option="option" v-model:search="search" v-model:page="page" v-model="form" :table-loading="loading"
      :data="data" :before-open="beforeOpen" ref="crud" @search-change="searchChange" @search-reset="searchReset"
      @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
      @refresh-change="refreshChange" @on-load="onLoad">
      <template #isPass="{ row }">
        <el-tag v-if="row.parVO.isPass == 0" type="danger">
          不及格
        </el-tag>
        <el-tag v-else type="success">
          及格
        </el-tag>
      </template>
      <template #assessType="{ row }">
        <el-tag v-if="row.assessType == 'department'" type="success">
          部门
        </el-tag>
        <el-tag v-else-if="row.assessType == 'teacher'" type="success">
          师傅
        </el-tag>
        <el-tag v-else-if="row.assessType == 'product'" type="success">
          型号
        </el-tag>
      </template>
      <template #status="{ row }">
        <div v-if="row.status == 1">待办理</div>
      </template>
      <template #hasChild="{ row }">
        <el-link type="primary" @click="handler_start_subjectiveResult(row)">评价</el-link>
      </template>
    </avue-crud>
    <EvaluationDialog ref="subjectivestartRef" :detail="examDetail" :type="subjectiveType" />
  </basic-container>
</template>

<script>
import { getList } from '@/api/position/managersubjectivetoresult';
import EvaluationDialog from './com/subjectivestarttodo.vue';
import option from './option_todo';
export default {
  components: {EvaluationDialog },
  data() {
    return {
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option,
      search: {},
      loading: false,
      data: [],
      form: {},
      examDetail: {},
      nextExamId: '',
      selectList: [],
      subjectiveType: '',
      data_source: []
    };
  },
  methods: {
    async getList() {
      this.loading = true;
      const res = await getList(this.page.currentPage, this.page.pageSize, this.search);
      this.data = res.data.data.records;
      this.page.total = res.data.data.total;
      this.loading = false;
    },
    beforeOpen(done, type) {
      if (['edit'].includes(type)) {

      }
      done();
    },
    searchChange(form, done) {
      this.getList();
      done();
    },
    searchReset() {
    },
    selectionChange(list) {
      this.selectList = list;
    },
    currentChange() {
    },
    sizeChange() {
    },
    refreshChange() {
    },
    onLoad() {
      this.getList();
    },
    handler_start_subjectiveResult(row) {
      this.examDetail = row;
      this.subjectiveType = "";
      this.$refs.subjectivestartRef.open()
      console.log(row);
      
    },
  }
};
</script>

<style lang="scss" scoped>
.q-cxt {
  display: flex;

  .q-c {
    width: 200px;
  }

  .q-list {
    flex: 1
  }

  .q-option {
    width: 200px;
  }
}
</style>
